const int numElementos = 10; 
int lecturas[numElementos];  
int index = 0;   
int total = 0;  
int media = 0; 
 
void setup(){
      Serial.begin(9600);                  
      for (i = 0; i < numElementos; i++){
          lecturas[i] = 0;          
      } 
}

void loop() {
     total= total - lecturas[index];        
     lecturas[index] = analogRead(2);
     total= total + lecturas[index];      
     index = index + 1;                    
     if (index >= numElementos){              
          index = 0;                          
     }
     media = total / numElementos;        
     Serial.println(media);  
     delay(1);
}



 




